package com.vgemv.jsutilitysdk;

import android.app.Application;
import android.content.Context;
import android.util.Log;

import com.vgemv.jsutilitysdk.Alert.JsAlertManager;
import com.vgemv.jsutilitysdk.Crash.JsCrashManager;
import com.vgemv.jsutilitysdk.Orientation.JsOrientationManager;
import com.vgemv.jsutilitysdk.Request.JsRequestManager.JsRequestManager;
import com.vgemv.jsutilitysdk.Request.JsRequestManager2.JsRequestManager2;
import com.vgemv.jsutilitysdk.SharedPreference.JsSharedPreferencesManager;
import com.vgemv.jsutilitysdk.file.JsFileManager;
import com.vgemv.jsutilitysdk.geometry.JsGeometryManager;
import com.vgemv.jsutilitysdk.log.JsLogManager;

public class JsUtilitySdkManager {
    public static String version = "0.0.56";
    public static String sdkName = "JsUtilitySdk";


    public static String getSdkInfo() {
        return getSdkInfo(0);
    }

    public static String getSdkInfo(int emptyLineNum) {
        StringBuffer sb = new StringBuffer();
        for ( int i = 0 ; i < emptyLineNum; i++) {
            sb.append(" \n");
        }
        sb.append(String.format("\n+++        %s          +++\n",sdkName));
        sb.append(String.format("%s             version:%s\n", sdkName,version));
        sb.append(String.format("===        %s          ===\n",sdkName));
        for ( int i = 0 ; i < emptyLineNum; i++) {
            sb.append(" \n");
        }
        String info = sb.toString();
        return info;
    }

    static public void printfVersion() {
        android.util.Log.i(sdkName,getSdkInfo(3));
    }


    /**
     * 初始化所有组件.
     * 鉴于很多组件的单例模式也需要Context上下文,统一用Application上下文初始化.
     * @param
     */
    static public void initSdk(Application app,String appName) {
        JsAlertManager.initClass(app);
        JsCrashManager.initClass(app);
        JsGeometryManager.initClass(app);
        JsOrientationManager.initClass(app);
        JsFileManager.initClass(app,appName);
        JsSharedPreferencesManager.initClass(app, appName);
        JsRequestManager.initClass(app,true);
        JsRequestManager2.initClass(app,true);

    }

    static {
//        printfVersion();
    }
}
